#include "WakeUpOnLANTask.h"
#include "IPEndpoint.h"
SK

WakeUpOnLANTask::WakeUpOnLANTask (byte *macAddr)
{
    soc = new Socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
	for (u32 i=0;i<6;i++)
		MAC[i] = macAddr [i];
}

WakeUpOnLANTask::~WakeUpOnLANTask ()
{
    delete soc;
}

void WakeUpOnLANTask::run (void)
{
    //build the packet
    KLib::IPEndpoint ep;
	ep.setBroadcast (9);
    byte magicPacket [102];
	byte mac [6];

	for (u32 i=0; i<6; i++)
	{
		magicPacket [i] = 0xFF;
	}

	for (u32 j=1; j<17;j++)
	{
		memcpy (&magicPacket [j*6], &MAC, sizeof (byte) * 6);
	}

	for (u32 i=0; i<100; i++)
	{
		//soc->sendTo (magicPacket, 102, ep);
        Sleep (1);
	}

}


EK